//
//  LeverDataModel.swift
//  Exchange
//
//  Created by 孟祥群 on 2018/7/6.
//  Copyright © 2018年 common. All rights reserved.
//

import UIKit

class LeverDataModel: BaseModel {
    var buyPrice:Double = 0.00 //买入价格
    var sellPrice:Double = 0.00 //卖出价格
    var limitNumber:Double = 0.00 //最小成交量
    var number:String = "" //交易数量
    var lowNumber:Double = 0.00 //最小数量
    var bail:[String] = [] //保证金选择的数值
    var lossScales:String = "" //止损浮动比例
    var profitScales:String = "" //止盈浮动比例
    //价格小数位数
    var priceDigit:Int = 0 {
        didSet {
            self.changeCalculationPrice(digit:priceDigit,priceBool:true)
        }
    }
    //数量小数位数
    var numDigit:Int = 0 {
        didSet {
           self.changeCalculationPrice(digit:numDigit)
        }
    }
    
    var calculationPrice:Double = 0 //价格的计价单位
    var calculationNum:Double = 0 //数量的计价单位
    
    
    
    var openSelect:Bool = false //是否打开止盈止损
    var stopLoss:String = "" //触发止损的价格
    var stopProfit:String = ""//止盈的价格
    var price:String = ""
    
    var isBuyBool = true
    
    var selectIndex:Int = 0 //选择的杠杆比例 默认第一个
    
    var coinPair:String = "" //币种对信息
    
    var coinAsset:Double = 0.00
    
    
    var limitloss:Double = 0.00 //触发止损最高价
    
    var limitProfit:Double = 0.00 //触发止盈最低价
    
    var tradePrice:Double = 0.00 //交易价格
    var coinPrice:String = "" //法币价格
    
    var tradeName:String = "" //保证金名称
    
    var bailInfo = ""
    
    var stopLossInfo = "" //触发指损描述
    var stopProfitInfo = "" //止盈描述
    
    
    

    
    /// 修改加减的数字
    ///
    /// - Parameter digit: 小数位数
    func changeCalculationPrice(digit:Int,priceBool:Bool = false) {
        var unitPrice:Double = 1
        for _ in 0..<digit {
            unitPrice = unitPrice / 10
        }
        if priceBool {
            calculationPrice = unitPrice
        }else {
            calculationNum = unitPrice
        }
    }

    
}

